package com.example.oj.controller;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.oj.common.Result;
import com.example.oj.entity.JudgerStatus;
import com.example.oj.mapper.JudgerStatusMapper;
import com.example.oj.service.JudgerStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class JudgerStatusController {

    @Autowired
    private JudgerStatusService judgerStatusService;

    @PostMapping("/judgerstatus")
    public Result<?>submitCode(@RequestBody JudgerStatus judgerStatus){
        judgerStatus.setSubmittime(new DateTime());
        judgerStatusService.save(judgerStatus);
        return Result.success();
    }
    @GetMapping("/allstatus")
    public Result<?> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
                              @RequestParam(defaultValue = "10") Integer pageSize,
                              @RequestParam(defaultValue = "") String select_pid,
                              @RequestParam(defaultValue = "") String select_username,
                              @RequestParam(defaultValue = "") String select_language,
                              @RequestParam(defaultValue = "") String select_status){
        Page<JudgerStatus> judgerStatusPage = judgerStatusService.SelectPage(pageNum, pageSize, select_pid,
                select_username, select_language, select_status);
        return Result.success(judgerStatusPage);
    }
}
